package swing_UI;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class ClientButtonHandler implements ActionListener{
	
	JFrame container;
	public ClientButtonHandler(JFrame container)
	{
		this.container = container;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		ClientButton caller = (ClientButton) e.getSource();
		Client.Status status = caller.getStatus();
		switch(status){
		case CONNECTED:
			ConnectionDisplay conn_info = new ConnectionDisplay();
			conn_info.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			conn_info.setVisible(true);
			break;
		case DISCONNECTED:
			ConnectDialog connect = new ConnectDialog();
			connect.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			connect.setVisible(true);
			break;
		case ERROR:
			JOptionPane.showMessageDialog(container, "Error: Server unable to connect to client as of Nov 28 2011, 23:43:21");
			break;
			
		
		}
	}

	
}
